package br.ufrgs.ga.model;

import br.ufrgs.ga.operators.ICrossover;
import br.ufrgs.ga.operators.IMutation;

public class GeneticModelFactory {

	/**
	 * Single instance of this factory.
	 */
	private static GeneticModelFactory instance;

	private GeneticModelFactory() { 
	}
	
	/**
	 * Implements the singleton pattern (this centralizes the way that instances of this class are created).
	 * @return ModelFactory instance.
	 */
	public static GeneticModelFactory getInstance() {
		if (instance == null) {
			instance = new GeneticModelFactory();
		}
		return instance;
	}
	
	/**
	 * Creates an instance of IChromosome.
	 * @param dnaStrand
	 * @return an instance of IChromosome
	 */
	public IChromosome<String> createChromosome(String dnaStrand) {
		return new TSPChromosome(dnaStrand);
	}
	
	public IChromosome<String> createChromosome(String dnaStrand, ICrossover<String> crossoverOperator) {
		return new TSPChromosome(dnaStrand, crossoverOperator);
	}
	
	public IChromosome<String> createChromosome(String dnaStrand, IMutation<String> mutationOperator) {
		return new TSPChromosome(dnaStrand, mutationOperator);
	}
	
	public IChromosome<String> createChromosome(String dnaStrand, ICrossover<String> crossoverOperator, IMutation<String> mutationOperator) {
		return new TSPChromosome(dnaStrand, mutationOperator);
	}
}